package com.jf.springcloud.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User:22954
 * Date:2025-02-28
 * Time:10:20
 */
@RequestMapping("/hotspot")
@RestController
public class HotspotController {
    @GetMapping("/news")
    @SentinelResource(value = "news", blockHandler = "blockHandler")
    public String news(@RequestParam("id") Integer id, @RequestParam("type") String type) {
        return "news id = " + id + "  type = " + type;
    }

    public String blockHandler(Integer id, String type, BlockException ex) {
        return "热点被限流了: id=" + id + ",  type=" + type;
    }
}
